import BaseNativeAdItemModel from "./base/BaseNativeAdItemModel";
export function isNull(obj: any): boolean {
    return obj == undefined || obj == null;
}


export class FileEncoding {
    static UTF8: string = 'utf8'
    static BINARY: string = 'binary'
}

export function random(start: number, end?: number): number {
    if (end) {
        return Math.floor(Math.random() * (end - start) + start)
    } else {
        return Math.floor(Math.random() * start);
    }
}
export function compareVersion(v1, v2): number {
    v1 = v1.split('.')
    v2 = v2.split('.')
    const len = Math.max(v1.length, v2.length)

    while (v1.length < len) {
        v1.push('0')
    }
    while (v2.length < len) {
        v2.push('0')
    }

    for (let i = 0; i < len; i++) {
        const num1 = parseInt(v1[i])
        const num2 = parseInt(v2[i])

        if (num1 > num2) {
            return 2
        } else if (num1 < num2) {
            return 0
        }
    }

    return 1
}

export type DataCallback = (result: ResultState, data: any) => void;
export type ResultCallback = (result: ResultState) => void
export type NativeAdCallback = (list: BaseNativeAdItemModel[]) => void;
//广告名称，对应SDKCOnfig中的key
export class ADName {
    static banner: string = 'banner'//bander 广告
    static reward: string = 'reward'//激励视频
    static insert: string = 'insert'//插屏广告
    static native: string = 'native'//原生广告
    static appbox: string = 'appbox'//盒子广告
    static grid: string = 'grid' //格子广告
    static block: string = 'block'//积木广告
    static shareTitle: string = 'shareTitle'//分享标题
    static shareImage: string = 'shareImage'//分享图片
    static imageUrlId: string = 'imageUrlId'
    static appid: string = 'appid'
    static customAd: string = 'customAd'
}


//广告拉取失败是否使用分享
export let USE_SHARE: boolean = false;

export enum BannerDir {
    BOTTOM_MID,
    BOTTOM_LEFT,
    TOP_MID,
    RIGHT_MID,
    MID,
    MID_DOWN,


}

export enum ResultState {
    NO,
    YES,
    PROGRESS,
}
/**
 * 广告状态
 * 
 */
export enum SDKState {
    close,//关闭状态
    loading,//加载状态
    loadSucess,//加载成功
    loadFail,//加载失败
    open,//播放状态
    clear,

}

/**
0	开发
1	微信
2	QQ
3	头条
4	OPPO
5	VIVO
6	百度
 */
export enum ChannelID {
    DEV,
    WX,
    QQ,
    TT,
    OPPO,
    VIVO,
    BD,//百度
}

export enum FunctionType {
    onLoad,
    onError,
    onClose,
    onResize,
    onHide,
}


export let SDKConfig: any[] = [
    {},//dev
    {//微信
        'banner': ['adunit-26984378608c61c0'],
        'reward': ['adunit-4a30627781abc04a'],
        'insert': ['adunit-42487eb8d3982eb6'],
        'grid': ['adunit-c8aeb0e5048b575d'],
        'customAd': ['adunit-53ce4c502c490700'],
        'shareTitle': ['[有人@你]来试试你的宠物能养到多大'],
        'shareImage': ['share.jpg'],//放到项目根目录
        'imageUrlId': ['7EZjxqk4SQe6xBrSrOuqLw==']
    },
    {//qq
        'banner': ['2f909f660b9c0454db968eea5ab9cd80', 'fe725cc0c5ed35f54391318c54de68fa'],
        'insert': ['ac756fb4a63ed6494d80d929006fae22'],
        'reward': ['6ef3422ca7cddae1658ca266af7ee6bb'],
        'appbox': ['a28b037b6dca143b7ca7090a7fe7efed'],
        'block': ['932d1ec81490347bde233e67129a6db1'],
        'shareTitle': ['[有人@你]来试试你的宠物能养到多大'],
        'shareImage': ['share.jpg'],
    },
    {//tt
        'banner': ['ig1is5ki76k2e4ab46', '1m636mj8o1fo6f363d', 'g0m96ahgh0o3i3882i'],
        'reward': ['1j66nga7w9ui63624e', '1j66nga7w9ui63624e', '1j66nga7w9ui63624e'],
        'insert': ['94lbc930s61a7orm4c', '40e2kt25w3g84824dj', 'n4llnec3fbj1e70jak'],
        'shareTitle': ['[有人@你]来试试你的宠物能养到多大'],
        'shareImage': ['share.jpg'],
        'imageUrlId': ['17p6mo65e22f9eggi8']
    },
    {//oppo
        'banner': [],
        'reward': [],
        'native': [],
        'insert': []
    },
    {//vivo
        'banner': ['71322bc6af0e4d2f8a7ab6ec0313552a', '3688244d5d7e44e583ea09a572821873'],
        'reward': ['4e826ea6cd214950a26a58a6c6c9e24a'],
        'insert': [],
        'native': ['079286cabff8472fb4e0c2b1fbdbf07d', 'd3c0d3c16f2b42bf88c3e541b8e20c3b']
    },
    {//baidu
        'appid': '22643039',
        'banner': ['7217267'],
        'reward': ['7217269']
    },


]

export class SDKEventName {
    static outdoor = 'outdoor'
    static tree = 'tree' // itemid
    static dress = 'dress'// itemid
    static make = 'make' // step
    static decuration = 'decuration'
    static enterwc = 'enterwc'
    static eating = 'eating'
    static badroom = 'badroom'
    static smallgame = 'smallgame'
    static enterlogin = 'enterlogin'
    static enterlobby = 'enterlobby'
    static enterhouse = 'enterhouse'
    static bathroom = 'bathroom'
    static entertree = 'entertree'
    static entersnow = 'entersnow'
    static born = 'born'
}

export enum BattleID {
    ENTER_GAME,
    ENTER_EXPORT2_RETURN_GAME,
    ENTER_EXPORT1_FROM_LOGIN,
    ENTER_EXPORT1_FROM_LOBBY,
    LOGIN_TO_LOBBY,
    HIT_EGG_TO_LOBBY,
    CLICK_PADA_RETURN_GAME,
    HIT_LOBBY_EGG_TO_LOBBY,
    EXPORT1_RETURN_GAME,
}

export let BattleName: string[] = [
    'n进入到登录',//ok
    'n导出页2返回',
    'n登陆到导出页1',//ok
    'n大厅到导出页1',//ok
    'n开始游戏到大厅',//ok
    'n登陆到砸蛋到大厅',//ok
    'n熊猫播放视返回',//ok
    'n大厅砸金到返回大厅',//ok
    'n导出页1返回大厅',//ok
]